#define _CRT_SECURE_NO_WARNINGS 1

int removeElement(int* nums, int numsSize, int val) {
    int x = 0;

    for (int i = 0; i < numsSize; i++)
    {
        if (nums[x] != val)
            x++;
        else if (nums[i] != val)
        {
            nums[x] = nums[i];
            nums[i] = val;
            x++;
        }
    }
    return x;
}